home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / viewkit / VCal / HelpDialog.c++ < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-02  |  20.2 KB  |  643 lines

  1. /*
  2.  * Copyright (C) 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17. #include <stdio.h>
  18. #include <malloc.h>
  19. #include <string.h>
  20. #include "HelpDialog.h"
  21.  
  22. #include <Xm/Text.h>
  23. #include <Xm/LabelG.h>
  24. #include <Xm/List.h>
  25. #include <Xm/Form.h>
  26.  
  27. static int count;
  28. static Arg args[10];
  29.  
  30. static char *helpText = "\
  31. OVERVIEW\n\
  32. ========\n\
  33. \n\
  34. VCal is a simple calendar program with alarms.  You can make entries\n\
  35. that are either single instance or repeating, and have alarm events.\n\
  36. \n\
  37. Current Features:\n\
  38. \n\
  39.     Appointments can have multiple alarm events, and alarm events can\n\
  40.     popup a dialog, send email, and/or execute a commmand.\n\
  41. \n\
  42.     Month and week overview displays.\n\
  43. \n\
  44.     Month PostScript printing, day/week/month ASCII output.\n\
  45. \n\
  46.     Multi-line text appointments.\n\
  47. \n\
  48.     Full control of configurable options through preferences dialog.\n\
  49. \n\
  50.     Support for multiple, simultaneous accessors of the same database.\n\
  51. \n\
  52. Current Limitations:\n\
  53. \n\
  54.     Modifications to repeating entries affect all instances.\n\
  55. \n\
  56.     The -daily, -weekly, -monthly, and -printMonth switches still require\n\
  57.     an X connection.\n\
  58. \n\
  59.     Alarm advance warnings not specified in days do not work across day\n\
  60.     boundaries.\n\
  61. \n\
  62.     Alarms scheduled to fire on a previous day will trigger at 12am on the\n\
  63.     the previous day if VCal is running, or at startup when VCal is started\n\
  64.     on the previous day.\n\
  65. \n\
  66.     You cannot delete an alarm's entry from the popup dialog if the entry\n\
  67.     is for a future day (i.e. the advance notice is measured in days).\n\
  68. \n\
  69. \n\
  70. MONTH VIEW\n\
  71. ==========\n\
  72. \n\
  73. The main window of VCal shows a single month.  Today, if visible, is\n\
  74. highlighted.  Clicking on a day changes the Day View to show the\n\
  75. entries for that day.  The Day View will be created as necessary.\n\
  76. If you hold down the Shift key while clicking on a day, the Week\n\
  77. Overview will be displayed instead.\n\
  78. \n\
  79. By default, a menubar is displayed in the Month View.  For a cleaner\n\
  80. appearance, users may want to hide the menubar using the Preferences\n\
  81. item under the File menu.  If you hide the menubar, you can still\n\
  82. access the menu items by right-clicking in the header area, to bring\n\
  83. up a popup menu with the same contents.\n\
  84. \n\
  85. Left-click in the header to move to the current month.  The left and\n\
  86. right arrows will decrement and increment the month, respectively.\n\
  87. \n\
  88. \n\
  89. DAY VIEW\n\
  90. ========\n\
  91. \n\
  92. The day view shows the entries for a single day.  By default, it only\n\
  93. shows the time range from 8am to 7pm.  A dotted line shows the current\n\
  94. time, if today is being viewed.  Change the Restricted toggle under the File\n\
  95. menu to alternate between restricted and 24-hour display.\n\
  96. \n\
  97. To create a new entry, left click to the right of the start time.\n\
  98. This will create a blank entry.  Enter the text for the entry,\n\
  99. pressing Return twice at the end to finalize it.  You can also\n\
  100. finalize the entry by left-clicking in the time area.\n\
  101. \n\
  102. Once you have created an entry, you can left-click on it to make it\n\
  103. editable again.  While you are editing an entry, grab areas will\n\
  104. appear in the lower-left and upper-right.  Use the left-button to\n\
  105. resize that corner (e.g. adjust the entry length), and the\n\
  106. right-button to move the entry (e.g. change the start time).  As you\n\
  107. make these adjustments, the time range for the entry will be displayed\n\
  108. to the left of the entry text.\n\
  109. \n\
  110. If you right-button in the entry, a popup menu will appear.  Select\n\
  111. Entry Attributes to examine and modify the entry-specific\n\
  112. parameters.  Select Delete Entry to remove that entry.  Erasing all\n\
  113. the text will also remove an entry.\n\
  114. \n\
  115. Left-click in the header to move to the current day.  The left and\n\
  116. right arrows will decrement and increment the day, respectively.\n\
  117. \n\
  118. \n\
  119. ENTRY ATTRIBUTES\n\
  120. ================\n\
  121. \n\
  122. Each entry has certain attributes associated with it, as well as the\n\
  123. entry text.\n\
  124. \n\
  125.   Entry Kind        Single instance, or some form of repeating.  Beware\n\
  126.               that changes or deletion of repeating entries affect\n\
  127.               all of the repeating instances.  There is currently\n\
  128.               no support for changing or deleting only a single\n\
  129.               instance of a repeating entry.\n\
  130. \n\
  131.   Annotate Day        This entry should cause this day to be colored in\n\
  132.               the Month View if the Annotate Month View\n\
  133.               preference is set.\n\
  134. \n\
  135.   Notification Popup    This entry causes an alarm dialog to post, if\n\
  136.               the Use Alarm Notifications prefence is set.\n\
  137. \n\
  138.   Notification Bell    This entry beeps the display, if\n\
  139.               the Use Alarm Notifications prefence is set.\n\
  140. \n\
  141.   Notification Mail    This entry sends mail to the user, if\n\
  142.               the Use Alarm Notifications prefence is set.\n\
  143. \n\
  144.   Notification Command    This entry executes a command, if\n\
  145.               the Use Alarm Notifications prefence is set.\n\
  146. \n\
  147.   Alarm Advance Notices    The delay(s) before the entry start when an alarm\n\
  148.                is posted, if the Use Alarm Notifications preference\n\
  149.                is set.  The default value is the Default Advance\n\
  150.                           Notice preference.  Separate multiple advance\n\
  151.               notices with commas, and specify units (min, hour,\n\
  152.               or day).  The default unit is minutes.\n\
  153. \n\
  154.   Repeat End Date    If this entry kind is repeating, the date to stop\n\
  155.               repeating.  No repeat end date indicates that\n\
  156.               the entry should repeat forever.\n\
  157. \n\
  158. \n\
  159. MONTH OVERVIEW\n\
  160. ==============\n\
  161. \n\
  162. The Month Overview is read-only, but you can click on a particular day\n\
  163. and have the Day View display that day's entries.  Use the navigation\n\
  164. arrows in the Month View to change the month displayed in the Month\n\
  165. Overview.  Change the Restricted toggle under the File menu to alternate\n\
  166. between restricted and 24-hour entry markers.\n\
  167. \n\
  168. \n\
  169. WEEK OVERVIEW\n\
  170. =============\n\
  171. \n\
  172. The Week Overview is read-only, but you can click on a entry and have\n\
  173. the Day View display that entry's day and time.  Use the navigation\n\
  174. arrows in the Day View or select a day in the Month View to change the\n\
  175. week displayed in the Week Overview.  Change the Restricted toggle under the\n\
  176. File menu to alternate between restricted and 24-hour display.\n\
  177. \n\
  178. \n\
  179. PREFERENCES\n\
  180. ===========\n\
  181. \n\
  182. VCal comes with a standard set of parameters that should be useful to\n\
  183. most users.  However, some users may want to customize VCal for their\n\
  184. own situation.  Use the Preferences item in the File menu of the Month\n\
  185. View to bring up the preferences dialog.\n\
  186. \n\
  187. Because of the complexity of all the preferences, the Revert To\n\
  188. Factory Preferences item in the File menu of the Month View will\n\
  189. change all but one preference back to the factory (default) settings.\n\
  190. The only preference not changed is Hide Menu Bar, Use Popup.\n\
  191. \n\
  192. The preferences are separated into four groups:\n\
  193. \n\
  194.   Configuration\n\
  195. \n\
  196.     Hide Menu Bar, Use Popup    Don't display a menubar in Month View. [off]\n\
  197. \n\
  198.     Show Time In Icon        Display the current time in the iconname,\n\
  199.                   for those who want a clock there.  This\n\
  200.                   prevents the screen saver from activating\n\
  201.                   in some SGI X displays. [off]\n\
  202. \n\
  203.     Show Date In Icon        Display the current date in the iconname.\n\
  204.                         [off]\n\
  205. \n\
  206.     Annotate Month View        Days with annotated-entries are colored. [on]\n\
  207. \n\
  208.     Show Late Appointments    When VCal is started, post alarms for\n\
  209.                   today's entries that have already happened.\n\
  210.                   [off]\n\
  211. \n\
  212.     Use 24-Hour Time Format     Display times in 24-hour format. [off]\n\
  213. \n\
  214.     Snooze Time            When an alarm is posted and the user selects\n\
  215.                   Snooze, the number of minutes before the\n\
  216.                   alarm fires again. [2]\n\
  217. \n\
  218.     Update Interval        Number of seconds between VCal time updates,\n\
  219.                   database checks for alarms, and file\n\
  220.                   modification checks for other writers. [60]\n\
  221. \n\
  222. \n\
  223.   Alarm\n\
  224. \n\
  225.     Use Alarm Notifications     For alarming entries, whether to trigger\n\
  226.                   alarms.  Some users may want to suspend\n\
  227.                   alarms temporarily.  Users who are examining\n\
  228.                   someone else's database and who don't want\n\
  229.                   alarms should set the *displayAlarms\n\
  230.                   resource to False instead of changing this\n\
  231.                   preference option, since doing so will\n\
  232.                   affect all readers of the database. [on]\n\
  233. \n\
  234.     Annotate Day By Default    The default setting of the Annotate Day\n\
  235.                   entry attribute. [on]\n\
  236. \n\
  237.     Notification Popup        Popup a dialog for an alarm. [on]\n\
  238. \n\
  239.     Notification Bell        Beep for an alarm. [on]\n\
  240. \n\
  241.     Confirm Popup Delete    Post a confirmation dialog before deleting an\n\
  242.                   entry with the Delete button in the popup. [on]\n\
  243. \n\
  244.     Notification Mail        Send mail for an alarm. [off]\n\
  245. \n\
  246.     Notification Command    Command to execute for an alarm.  For instance,\n\
  247.                   one to play a sound file. [null]\n\
  248. \n\
  249.     Default Advance Notice(s)    For alarming entries, trigger alarms at\n\
  250.                   these intervals, separated by commas.\n\
  251.                   [5 min]\n\
  252. \n\
  253. \n\
  254.   Day View\n\
  255. \n\
  256.     Default Entry Length    When a new entry is created, the initial\n\
  257.                   length in minutes. [60]\n\
  258. \n\
  259.     Day View Entry Length    The number of minutes between major time\n\
  260.                   divisions in Day View. [60]\n\
  261. \n\
  262.     Number of Day View Subdiv    The number of subdivisions between major\n\
  263.                   time divisions in Day View.  Entry\n\
  264.                   start and finish will be restricted to\n\
  265.                   this time granularity. [4]\n\
  266. \n\
  267.     Day View Snap Interval    When a new entry is created, it is forced\n\
  268.                   to start at one of the time subdivisions\n\
  269.                   separated by this number of minutes. [30]\n\
  270. \n\
  271.     Restrict Day View        Instead of displaying the full 24-hours\n\
  272.                   of the say, show only a selected range.\n\
  273.                   See Restricted Start Hour and Restricted\n\
  274.                   Stop Hour. [on]\n\
  275. \n\
  276.     Restricted Start Hour    When Day View is restricted, the first\n\
  277.                   hour (in 24-hour format) displayed. [8]\n\
  278. \n\
  279.     Restricted Stop Hour    When Day View is restricted, the first hour\n\
  280.                   (in 24-hour format) hidden.  The remainder\n\
  281.                   of the day is hidden. [9]\n\
  282. \n\
  283. \n\
  284.   Database\n\
  285. \n\
  286.     Calendar Database Filename    Where to store the entry information. [~/.vcal]\n\
  287. \n\
  288.     Annotate File Contents    Add comment information to the saved database\n\
  289.                   file to reveal the file format. [off]\n\
  290. \n\
  291.     Automatically Save Changes    Save the database file whenever a change is\n\
  292.                   made, so the user never has to worry about\n\
  293.                   explicitly saving their changes. [on]\n\
  294. \n\
  295. \n\
  296. DATABASE FILES\n\
  297. ==============\n\
  298. \n\
  299. VCal allows multiple readers of the same database file.  To specify a\n\
  300. database file on the command-line, use the -filename option.  When\n\
  301. someone modifies the file, VCal will notice the change and update its\n\
  302. display.  If there are unsaved changes (unlikely, when the\n\
  303. Automatically Save Changes preference is set), you will be warned and\n\
  304. asked if you want to flush your changes.\n\
  305. \n\
  306. Different preference settings are associated with different database\n\
  307. files, so individual database owners can maintain their own\n\
  308. preferences.\n\
  309. \n\
  310. \n\
  311. X RESOURCES\n\
  312. ===========\n\
  313. \n\
  314. All preferences are controlled via the preferences dialog.  However,\n\
  315. there are some useful things to put in your .Xdefaults.\n\
  316. \n\
  317. To display the Month View without a window manager titlebar with 4Dwm, add:\n\
  318. \n\
  319.   4Dwm*vcal*clientDecoration:   -title\n\
  320. \n\
  321. To change the color scheme, choose a scheme name from one of the\n\
  322. subdirectories of /usr/lib/X11/schemes and add something like:\n\
  323. \n\
  324.   Vcal*scheme:            VanGogh\n\
  325. \n\
  326. To use a smaller font on non-Indigo/Entry systems, add:\n\
  327. \n\
  328.   Vcal*useSmallFonts:        True\n\
  329. \n\
  330. To examine someone else's database and not have alarm events regardless\n\
  331. of the Use Alarm Notifications setting, add:\n\
  332. \n\
  333.   Vcal*displayAlarms:        False\n\
  334. \n\
  335. To change the day annotation color, add something like:\n\
  336. \n\
  337.   Vcal*annotateColor:           red\n\
  338. \n\
  339. To automatically place and size the different VCal windows, add\n\
  340. geometry settings in your .Xdefaults like the following.  It is\n\
  341. important that the character before \"geometry\" be a period and not\n\
  342. an asterix!\n\
  343. \n\
  344.   Vcal.geometry:                  220x175-195+0\n\
  345.   Vcal*dayView.geometry:          +445+155\n\
  346.   Vcal*monthOverview.geometry:    400x390-0+225\n\
  347.   Vcal*weekOverview.geometry:     -0-0\n\
  348. \n\
  349. \n\
  350. COMMAND-LINE OPTIONS\n\
  351. ====================\n\
  352. \n\
  353.   -file database-file\n\
  354.         This option allows the user to specify a different\n\
  355.         calendar file.  The default file is \"~/.vcal\".  VCal\n\
  356.         supports multiple accessors of the same file, and\n\
  357.         will update when someone else changes the same file.\n\
  358. \n\
  359.   -title window-title\n\
  360.         This option specifies the window title used by VCal.\n\
  361.         The default value is \"VCal\".\n\
  362. \n\
  363.   -iconName icon-name\n\
  364.         This option specifies the icon name used by VCal.\n\
  365.         The default value is \"vcal\".\n\
  366. \n\
  367.   -scheme color-scheme\n\
  368.         VCal supports color schemes.  To select a color\n\
  369.         scheme, choose the name of one of the subdirectories\n\
  370.         under /usr/lib/X11/schemes.\n\
  371. \n\
  372.   -day date\n\
  373.         This option displays the appointments for the\n\
  374.         specified day to stdout.  Use \"today\" to indicate today's date.\n\
  375. \n\
  376.   -week date\n\
  377.         This option displays the appointments for the\n\
  378.         specified week to stdout.  Use \"today\" to indicate today's date.\n\
  379. \n\
  380.   -month date\n\
  381.         This option displays the appointments for the\n\
  382.         specified month to stdout.  Use \"today\" to indicate today's date.\n\
  383. \n\
  384.   -printMonth date\n\
  385.         This option emits PostScript to stdout, suitable for\n\
  386.         printing the calendar for the month with entries.  Use \"today\" to\n\
  387.         indicate today's date.\n\
  388. \n\
  389. \n\
  390. LIMITATIONS\n\
  391. ===========\n\
  392. \n\
  393. Modifications to repeating entries affect all instances.\n\
  394. \n\
  395. The -daily, -weekly, -monthly command-line switches still require an X\n\
  396. connection.\n\
  397. \n\
  398. Alarm advance warnings not specified in days do not work across day\n\
  399. boundaries.\n\
  400. \n\
  401. Alarms scheduled to fire on a previous day will trigger at 12am on the\n\
  402. the previous day if VCal is running, or at startup when VCal is\n\
  403. started on the previous day.\n\
  404. \n\
  405. You cannot delete an alarm's entry from the popup dialog if the entry\n\
  406. is for a future day (i.e. the advance notice is measured in days).\n\
  407. \n\
  408. When printing, do not select the \"Link in spool directory\" option because\n\
  409. VCal removes the temporary file immediately.\n\
  410. \n\
  411. \n\
  412. COMMENTS\n\
  413. ========\n\
  414. \n\
  415. Motif 1.2 provides drag and drop support when the middle mouse button\n\
  416. is used.  A little \"page\" icon will appear when you click with the\n\
  417. middle mouse in some areas.  Currently, VCal doesn't support drag and\n\
  418. drop in its interface so there will be little effect.\n\
  419. \n\
  420. It is not advised to set the Show Time In Icon preference, since doing\n\
  421. so may disable the screen saver functionality.\n\
  422. \n\
  423. \n\
  424. POSSIBLE ENHANCEMENTS\n\
  425. =====================\n\
  426. \n\
  427. Ability to modify or delete single instances of repeating entries.\n\
  428. \n\
  429. Day PostScript printing.\n\
  430. \n\
  431. Merged calendar files for comparison, scheduling, holidays, etc.\n\
  432. \n\
  433. Daily note entry.\n\
  434. \n\
  435. Enhanced command-line interface.\n\
  436. \n\
  437. \n\
  438. CREDITS\n\
  439. =======\n\
  440. \n\
  441. The PostScript program for printing the month came from Ken Keirnan's\n\
  442. pcal package, and was originally Copyright (c) 1987 by Patrick Wood\n\
  443. and Pipeline Associates, Inc. with permission to modify and redistribute.\n\
  444. \n\
  445. \n\
  446. Send bugs, comments, suggestions, and monetary gifts to mikey@sgi.com.\n\
  447. \n\
  448. Copyright 1994, Silicon Graphics, Inc.  All Rights Reserved.\n\
  449. \n\
  450. ";
  451.  
  452. HelpDialog::HelpDialog(const char *docName)
  453. : VkSimpleWindow(docName)
  454. {
  455.   info = NULL;
  456.   numInfo = 0;
  457. }
  458.  
  459. HelpDialog::~HelpDialog()
  460. {
  461.   int each;
  462.  
  463.   if (numInfo) {
  464.     for (each=0; each<numInfo; each++) {
  465.       free(info[each].topic);
  466.     }
  467.     free(info);
  468.   }
  469. }
  470.  
  471. const char *
  472. HelpDialog::className()
  473. {
  474.   return "HelpDialog";
  475. }
  476.  
  477. /**********************************************************************/
  478.  
  479. void
  480. HelpDialog::topicSelect(char *topic)
  481. {
  482.   int each;
  483.  
  484.   for (each=0; each<numInfo; each++) {
  485.     if (!strcasecmp(topic, info[each].topic)) {
  486.       topicSelect(each);
  487.       XmListSelectPos(list, each+1, False);
  488.       break;
  489.     }
  490.   }
  491. }
  492.  
  493. /**********************************************************************/
  494.  
  495. Widget
  496. HelpDialog::setUpInterface(Widget parent)
  497. {
  498.   Widget scroll, hs;
  499.  
  500.   count = 0;
  501.   form = XmCreateForm(parent, "form", args, count);
  502.  
  503.   count = 0;
  504.   XtSetArg(args[count], XmNtopAttachment, XmATTACH_FORM);  count++;
  505.   XtSetArg(args[count], XmNrightAttachment, XmATTACH_FORM);  count++;
  506.   label = XmCreateLabelGadget(form, "label", args, count);
  507.   XtManageChild(label);
  508.  
  509.   count = 0;
  510.   XtSetArg(args[count], XmNselectionPolicy, XmSINGLE_SELECT);  count++;
  511.   XtSetArg(args[count], XmNtopAttachment, XmATTACH_WIDGET);  count++;
  512.   XtSetArg(args[count], XmNtopWidget, label);  count++;
  513.   XtSetArg(args[count], XmNleftAttachment, XmATTACH_OPPOSITE_WIDGET);  count++;
  514.   XtSetArg(args[count], XmNleftWidget, label);  count++;
  515.   XtSetArg(args[count], XmNrightAttachment, XmATTACH_FORM);  count++;
  516.   XtSetArg(args[count], XmNbottomAttachment, XmATTACH_FORM);  count++;
  517.   list = XmCreateScrolledList(form, "list", args, count);
  518.   XtManageChild(list);
  519.   XtAddCallback(list, XmNsingleSelectionCallback,
  520.         HelpDialog::topic_select, (XtPointer) this);
  521.  
  522.   count = 0;
  523.   XtSetArg(args[count], XmNtopAttachment, XmATTACH_FORM);  count++;
  524.   XtSetArg(args[count], XmNleftAttachment, XmATTACH_FORM);  count++;
  525.   XtSetArg(args[count], XmNbottomAttachment, XmATTACH_FORM);  count++;
  526.   XtSetArg(args[count], XmNrightAttachment, XmATTACH_WIDGET);  count++;
  527.   XtSetArg(args[count], XmNrightWidget, XtParent(list));  count++;
  528.   text = XmCreateScrolledText(form, "helpText", args, count);
  529.   XtManageChild(text);
  530.  
  531.   displayHelp();
  532.  
  533.   scroll = XtParent(text);
  534.   count = 0;
  535.   XtSetArg(args[count], XmNhorizontalScrollBar, &hs);  count++;
  536.   XtGetValues(scroll, args, count);
  537.   if (hs) {
  538.     XtUnmanageChild(hs);
  539.   }
  540.  
  541.   XtManageChild(form);
  542.   return form;
  543. }
  544.  
  545. void
  546. HelpDialog::handleWmDeleteMessage()
  547. {
  548.   hide();
  549. }
  550.  
  551. void
  552. HelpDialog::displayHelp()
  553. {
  554.   XmTextSetString(text, helpText);
  555.   createIndex();
  556. }
  557.  
  558. void
  559. HelpDialog::createIndex()
  560. {
  561.   char *p, *q, *r;
  562.   Boolean first;
  563.  
  564.   first = True;
  565.   p = helpText;
  566.   while (*p != '\0') {
  567.     while (*p != '=' && *p != '\0') {
  568.       p++;
  569.     }
  570.     if (*p != '\0') {
  571.       if (first) {
  572.     q = helpText-1;
  573.     first = False;
  574.       } else {
  575.     q = p;
  576.     while (*q != '\n') {
  577.       q--;
  578.     }
  579.     q--;
  580.     while (*q != '\n') {
  581.       q--;
  582.     }
  583.       }
  584.       r = strchr(q+1, '\n');
  585.       *r = '\0';
  586.       addIndex(q+1, q+1-helpText);
  587.       *r = '\n';
  588.       while (*p == '=') {
  589.     p++;
  590.       }
  591.     }
  592.   }
  593. }
  594.  
  595. void
  596. HelpDialog::addIndex(char *topic, int offset)
  597. {
  598.   char *p;
  599.   XmString xs;
  600.  
  601.   if (numInfo) {
  602.     info = (HelpIndexInfo *) realloc(info, (numInfo+1)*sizeof(HelpIndexInfo));
  603.   } else {
  604.     info = (HelpIndexInfo *) malloc(sizeof(HelpIndexInfo));
  605.   }
  606.   info[numInfo].topic = strdup(topic);
  607.   p = info[numInfo].topic;
  608.   while (*p != '\0') {
  609.     if (p == info[numInfo].topic || *(p-1) == ' ' || *(p-1) == '-' ||
  610.     *(p-1) == '/') {
  611.       if (*p >= 'a' && *p <= 'z') {
  612.     *p = (*p + 'A' - 'a');
  613.       }
  614.     } else {
  615.       if (*p >= 'A' && *p <= 'Z') {
  616.     *p = (*p + 'a' - 'A');
  617.       }
  618.     }
  619.     p++;
  620.   }
  621.   info[numInfo].offset = offset;
  622.   xs = XmStringCreateSimple(info[numInfo].topic);
  623.   XmListAddItem(list, xs, 0);
  624.   numInfo++;
  625. }
  626.  
  627. void
  628. HelpDialog::topicSelect(int index)
  629. {
  630.   XmTextSetTopCharacter(text, info[index].offset);
  631. }
  632.  
  633. /**********************************************************************/
  634.  
  635. void
  636. HelpDialog::topic_select(Widget, XtPointer clientData, XtPointer callData)
  637. {
  638.   HelpDialog *obj = (HelpDialog *) clientData;
  639.   XmListCallbackStruct *cb = (XmListCallbackStruct *) callData;
  640.  
  641.   obj->topicSelect(cb->item_position-1);
  642. }
  643.